import numpy as np
import matplotlib.pyplot as plt

def createdCanvas(titleName="函数图像"):
    plt.title(titleName)
    plt.xlabel('x')
    plt.ylabel('y')
    plt.xlim((0,10))
    plt.ylim((0,10))
    plt.xticks(np.arange(0,11,1))
    plt.yticks(np.arange(0,11,1))


numData=np.arange(0,10,0.01)
p1=plt.figure(figsize=(12,6),dpi=100)

ax1=p1.add_subplot(2,1,1)
createdCanvas("y=x^2")
plt.plot(numData,numData ** 2)

ax2=p1.add_subplot(2,1,2)
createdCanvas("y=cos(x)")
plt.plot(numData,np.cos(numData)+2)

plt.show()